using System.Globalization;
using System.Windows.Data;
using System.Windows.Media;
using DimensionsHelper.Common.Contracts;

namespace DimensionsHelper.Client.Converters;

public class MessageTypeToBrushConverter : IValueConverter
{
    public Brush InfoBrush { get; set; } = Brushes.Black;

    public Brush ErrorBrush { get; set; } = Brushes.OrangeRed;

    public Brush WarningBrush { get; set; } = Brushes.Yellow;


    public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
    {
        if (value is not ReportMessageType level)
        {
            return InfoBrush;
        }

        return level switch
        {
            ReportMessageType.Info => InfoBrush,
            ReportMessageType.Error => ErrorBrush,
            _ => WarningBrush
        };
    }

    public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
    {
        return Binding.DoNothing;
    }
}